package cn.wenxin;

import cn.wenxin.entity.User;
import cn.wenxin.utils.ExcelUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException {
        try (
                InputStream in = Main.class.getClassLoader().getResourceAsStream("users.xlsx");
                Workbook workbook = WorkbookFactory.create(in);
        ) {
            List<User> users = ExcelUtils.toObject(workbook, new String[]{"name", "age", "email"}, User.class);
            System.out.println(Arrays.toString(users.toArray()));
        }

    }

}
